<!DOCTYPE html>
<html>

<head>
	<!-- 页面meta -->
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">

	<title>个人中心</title>

	<meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

	<link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="../plugins/ionicons/css/ionicons.min.css">
	<link rel="stylesheet" href="../plugins/iCheck/square/blue.css">
	<link rel="stylesheet" href="../plugins/morris/morris.css">
	<link rel="stylesheet" href="../plugins/jvectormap/jquery-jvectormap-1.2.2.css">
	<link rel="stylesheet" href="../plugins/datepicker/datepicker3.css">
	<link rel="stylesheet" href="../plugins/daterangepicker/daterangepicker.css">
	<link rel="stylesheet" href="../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
	<link rel="stylesheet" href="../plugins/datatables/dataTables.bootstrap.css">
	<link rel="stylesheet" href="../plugins/treeTable/jquery.treetable.css">
	<link rel="stylesheet" href="../plugins/treeTable/jquery.treetable.theme.default.css">
	<link rel="stylesheet" href="../plugins/select2/select2.css">
	<link rel="stylesheet" href="../plugins/colorpicker/bootstrap-colorpicker.min.css">
	<link rel="stylesheet" href="../plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
	<link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
	<link rel="stylesheet" href="../plugins/adminLTE/css/skins/_all-skins.min.css">
	<link rel="stylesheet" href="../css/style.css">
	<link rel="stylesheet" href="../plugins/ionslider/ion.rangeSlider.css">
	<link rel="stylesheet" href="../plugins/ionslider/ion.rangeSlider.skinNice.css">
	<link rel="stylesheet" href="../plugins/bootstrap-slider/slider.css">
	<link rel="stylesheet" href="../plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">
	<link rel="stylesheet" href="../css/user-info.css" />
	<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
	<script src="../js/jwt-decode.js"></script>


	<style>
		.disabled {
			cursor: not-allowed !important;
		}
	</style>


</head>

<body class="hold-transition skin-purple sidebar-mini">

	<div class="wrapper" style="overflow-y: hidden;">

		<!-- 页面头部 -->
		<header class="main-header">

			<!-- Logo -->
			<a href="common-index.html" class="logo">
				<!-- 侧边栏迷你logo，尺寸为50x50像素 -->
				<span class="logo-mini"><b>电子钱包</b></span>
				<!-- 常规状态和移动设备的logo -->
				<span class="logo-lg"><b>电子钱包</b>后台管理</span>
			</a>

			<!-- 头部导航栏：样式可以在header.less中找到 -->
			<nav class="navbar navbar-static-top">
				<!-- 侧边栏切换按钮 -->
				<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
					<span class="sr-only">Toggle navigation</span>
				</a>

				<div class="navbar-custom-menu">
					<ul class="nav navbar-nav">

						<li class="dropdown user user-menu">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">
								<img src="" class="user-image all-avatar-image">
								<span class="hidden-xs employee-name"></span>
							</a>

							<ul class="dropdown-menu">
								<!-- 用户图片 -->
								<li class="user-header">
									<img src="" class="img-circle all-avatar-image">

									<p class="employee-name"></p>
								</li>

								<li class="user-footer">
									<div class="pull-left">
										<a href="employee-info.html" class="btn btn-default btn-flat">修改信息</a>
									</div>
									<div class="pull-right">
										<a href="javascript:void(0);" class="btn btn-default btn-flat"
											id="logoutBtn">退出账号</a>
									</div>
								</li>
							</ul>
						</li>

					</ul>
				</div>
			</nav>
		</header>
		<!-- 页面头部 /-->

		<!-- 导航侧栏 -->
		<aside class="main-sidebar">
			<!-- 侧边栏：样式可以在sidebar.less中找到 -->
			<section class="sidebar">
				<!-- 侧边栏用户面板 -->
				<div class="user-panel">
					<div class="pull-left image">
						<img src="" class="img-circle all-avatar-image">
					</div>
					<div class="pull-left info">
						<p class="employee-name"></p>
						<a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
					</div>
				</div>

				<ul class="sidebar-menu">
					<li class="header">菜单</li>

					<li id="admin-index"><a href="common-index.html"><i class="fa fa-dashboard"></i> <span>首页</span></a>
					</li>

					<!-- 菜单 -->

					<li class="treeview">
						<a href="#">
							<i class="fa fa-folder"></i>
							<span>系统管理</span>
							<span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
						</a>
						<ul class="treeview-menu">

							<li id="admin-role-manage">
								<a href="role-list.html">
									<i class="fa fa-circle-o"></i> 角色管理
								</a>
							</li>

							<li id="admin-datalist">
								<a href="employee-list.html">
									<i class="fa fa-circle-o"></i> 员工管理
								</a>
							</li>

							<li id="admin-user-manage">
								<a href="user-list.html">
									<i class="fa fa-circle-o"></i> 用户管理
								</a>
							</li>

							<li id="admin-profile">
								<a href="employee-info.html">
									<i class="fa fa-circle-o"></i> 个人中心
								</a>
							</li>

						</ul>
					</li>



					<li class="treeview">
						<a href="#">
							<i class="fa fa-pie-chart"></i> <span>业务管理</span>
							<span class="pull-right-container">
								<i class="fa fa-angle-left pull-right"></i>
							</span>
						</a>
						<ul class="treeview-menu">

							<li id="history-list">
								<a href="history-list.html">
									<i class="fa fa-circle-o"></i> 历史记录管理
								</a>
							</li>

						</ul>
					</li>

				</ul>
			</section>

		</aside>
		<!-- 导航侧栏 /-->

		<!-- 内容区域 -->
		<!-- @@master = admin-layout.html-->
		<!-- @@block = content -->

		<div class="content-wrapper">

			<!-- 内容头部 -->
			<section class="content-header">
				<h1>
					首页
					<small>个人中心</small>
				</h1>
				<ol class="breadcrumb">
					<li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
					<li><a href="#">模块名称</a></li>
					<li class="active">模块功能</li>
				</ol>
			</section>
			<!-- 内容头部 /-->

			<!-- 正文区域 -->
			<section class="content">

				<div class="box box-primary col-sm-12">
					<div class="box-header with-border col-md-12 col-lg-12 col-sm-12">

						<div class="box-userinfo col-md-3 col-sm-10 col-lg-3">
						</div>

						<div class="box-userinfo-right col-lg-8 col-md-12 col-sm-10">
							<h2>基本资料</h2>
							<div class="box-userinfo-right-form">
								<h3>
									<span id="base-info">基本资料</span>
									<span id="update-password">修改密码</span>
								</h3>
								<form action="" class="box-userinfo-right-form-base">
									<li class="col-sm-12" style="height: 60px;margin-top: 20px;">
										<div class="form-group" style="position: relative;">
											<label for="userinfo-name"
												class="col-sm-3 col-md-2 control-label">姓名</label>
											<div class="col-sm-9 col-md-10">
												<input type="text" class="form-control" id="userinfo-name"
													placeholder="姓名" maxlength="12">
												<span id="userinfo-name-tip"
													style="display:none;color:red;position:absolute;top:20px">姓名不能为空且必须为中文</span>
											</div>
										</div>
									</li>
									<li class="col-sm-12" style="height: 60px;">
										<div class="form-group" style="position: relative;">
											<label for="userinfo-tel"
												class="col-sm-3 col-md-2 control-label">手机号码</label>
											<div class="col-sm-9 col-md-10">
												<input type="text" class="form-control" id="userinfo-tel"
													placeholder="手机号码" maxlength="11">
												<span id="userinfo-tel-tip"
													style="display:none;color:red;position:absolute;top:20px">手机号码格式不正确</span>
											</div>
										</div>
									</li>
									<li class="col-sm-12" style="height: 60px;">
										<div class="form-group" style="position: relative;">
											<label for="userinfo-email"
												class="col-sm-3 col-md-2 control-label">邮箱</label>
											<div class="col-sm-9 col-md-10">
												<input type="email" class="form-control" id="userinfo-email"
													placeholder="邮箱" maxlength="30">
												<span id="userinfo-email-tip"
													style="display:none;color:red;position:absolute;top:20px">邮箱格式不正确</span>
											</div>
										</div>
									</li>
									<li class="col-sm-12" style="height: 60px;">
										<div class="form-group" style="position: relative;">
											<label for="userinfo-bron"
												class="col-sm-3 col-md-2 control-label">出生日期</label>
											<div class="col-sm-9 col-md-10 ">
												<input type="date" class="form-control" id="userinfo-bron"
													placeholder="出生日期">
												<span id="userinfo-bron-tip"
													style="display:none;color:red;position:absolute;top:20px">日期格式不正确</span>
											</div>
										</div>
									</li>
									<li class="col-sm-12 col-md-12">
										<div class="form-group">
											<label class="col-sm-3 col-md-2 control-label">性别</label>
											<div class="col-sm-9 col-md-10">
												<label class="radio-inline">
													<input type="radio" name="inlineRadioOptions" id="inlineRadio1"
														value="男"> 男
												</label>
												<label class="radio-inline">
													<input type="radio" name="inlineRadioOptions" id="inlineRadio2"
														value="女" checked> 女
												</label>
											</div>
										</div>
									</li>
									<li class="col-sm-12">
										<div class="form-group">
											<button class="box-userinfo-right-btn-save" type="button"
												id="update-userInfo-button">保存</button>
										</div>
									</li>
								</form>

								<form class="box-userinfo-right-form-update" style="display: none;">
									<li class="col-sm-12 col-md-12" style="height: 60px;margin-top: 20px;">
										<div class="form-group">
											<label for="userinfo-oldPassword"
												class="col-sm-3 col-md-2 control-label"><span>*</span>旧密码</label>
											<div class="col-sm-9 col-md-10">
												<input type="password" class="form-control" id="userinfo-oldPassword"
													name="oldPassword" placeholder="请输入旧密码" maxlength="12">
												<span id="userinfo-oldPassword-tip"
													style="display:none;color:red;position:absolute;top:20px">密码格式不正确</span>
											</div>
										</div>
									</li>
									<li class="col-sm-12" style="height: 60px;">

										<div class="form-group">
											<label for="userinfo-newPassword"
												class="col-sm-3 col-md-2 control-label"><span>*</span>新密码</label>
											<div class="col-sm-9 col-md-10">
												<input type="password" class="form-control" id="userinfo-newPassword"
													name="newPassword" placeholder="请输入新密码" maxlength="12">
												<span id="userinfo-newPassword-tip"
													style="display:none;color:red;position:absolute;top:20px">密码格式不正确</span>
											</div>
										</div>
									</li>

									<li class="col-sm-12" style="height: 60px;">

										<div class="form-group">
											<label for="userinfo-newPassowrd-again"
												class="col-sm-3 col-md-2 control-label"><span>*</span>确认密码</label>
											<div class="col-sm-9 col-md-10">
												<input type="password" class="form-control" name="againNewPassword"
													id="userinfo-newPassowrd-again" placeholder="请确认新密码" maxlength="12">
												<span id="userinfo-againNewPassword-tip"
													style="display:none;color:red;position:absolute;top:20px">两次密码不一致</span>
											</div>
										</div>
									</li>

									<li class="col-sm-12 col-md-12">
										<div class="form-group">
											<button class="box-userinfo-right-btn-save" id="updae-password-button"
												type="button">保存</button>
										</div>
									</li>
								</form>

							</div>
						</div>

					</div>

				</div>

			</section>
			<!-- 正文区域 /-->


		</div>
		<!-- @@close -->
		<!-- 内容区域 /-->

		<!-- 底部导航 -->
		<footer class="main-footer">
			<strong>Copyright &copy; <a href="">电子钱包</a>.</strong> All rights reserved.
		</footer>
		<!-- 底部导航 /-->

	</div>

	<script type="text/javascript">

		// 顶部与侧边栏信息渲染,注销按钮
		$(document).ready(function () {
			var token = localStorage.getItem('token');
			var longToken = localStorage.getItem('longToken');

			// 获取注销按钮
			var logoutBtn = $("#logoutBtn");

			// 为注销按钮添加点击事件
			logoutBtn.click(function () {
				// 清除本地存储的 token 和 longToken
				localStorage.removeItem('token');
				localStorage.removeItem('longToken');
				// 跳转到登录
				window.location.href = 'employee-login.html';
			});

			if (token && longToken) {
				var decoded = jwt_decode(longToken);
				var userId = decoded.userId;

				getInfo(userId, token, longToken);
			} else {
				// 跳转到登录页面
				window.location.href = 'employee-login.html';
			}
		});

		// 获取个人数据，渲染侧边栏和头部
		function getInfo(userId, token, longToken) {
			var url = 'http://localhost:8080/employee/findByIdController?userId=' + userId;

			if (token && longToken) {
				url += '&token=' + token + '&longToken=' + longToken;
			}

			// 发送 AJAX 请求获取数据
			$.ajax({
				url: url,
				method: 'get',
				success: function (result) {

					if (result.code === 200) {
						var datas = result.datas;
						var imageUrl = "http://localhost:8080/" + datas.imageAddress;

						var imgs = document.querySelectorAll('img.all-avatar-image');
						imgs.forEach(function (img) {
							img.src = imageUrl;
						});

						var elements = document.querySelectorAll('.employee-name');
						elements.forEach(function (el) {
							el.innerHTML = datas.userName;
						});

					} else if (result.code === 6000 || result.code === 4000) {
						// 跳转到登录
						window.location.href = 'employee-login.html';
					} else {
						alert("获取数据失败");
					}

				},
				error: function (xhr, status, error) {
					console.log("请求失败");
				}
			});
		}

		// 页面加载完成后调用获取数据函数
		$(document).ready(function () {

			var nameInput = $("#userinfo-name");
			var nameTip = $("#userinfo-name-tip");
			var telInput = $("#userinfo-tel");
			var telTip = $("#userinfo-tel-tip");
			var emailInput = $("#userinfo-email");
			var emailTip = $("#userinfo-email-tip");
			var bornInput = $("#userinfo-bron");
			var bornTip = $("#userinfo-bron-tip");
			var saveButton = $("#update-userInfo-button");

			// 姓名格式验证
			nameInput.blur(function () {
				var name = nameInput.val();
				var reg = /^[\u4e00-\u9fa5]+$/; // 中文正则表达式
				if (name.trim() === "" || !reg.test(name)) { // 如果姓名为空或不是中文
					nameTip.show();
				} else {
					nameTip.hide();
				}
				checkAllInputs(); // 检查所有输入框是否都通过验证
			});

			// 手机号码格式验证
			telInput.blur(function () {
				var tel = telInput.val();
				if (!/^1[3456789]\d{9}$/.test(tel)) {
					telTip.show();
				} else {
					telTip.hide();
				}
				checkAllInputs(); // 检查所有输入框是否都通过验证
			});

			// 邮箱格式验证
			emailInput.blur(function () {
				var email = emailInput.val();
				if (!/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(email)) {
					emailTip.show();
				} else {
					emailTip.hide();
				}
				checkAllInputs(); // 检查所有输入框是否都通过验证
			});

			// 生日格式验证
			bornInput.blur(function () {
				var born = bornInput.val();
				if (!/^\d{4}-\d{2}-\d{2}$/.test(born)) {
					bornTip.show();
				} else {
					bornTip.hide();
				}
				checkAllInputs(); // 检查所有输入框是否都通过验证
			});

			// 检查所有输入框是否都通过验证
			function checkAllInputs() {
				if (/^[\u4e00-\u9fa5]+$/.test(nameInput.val()) &&
					/^1[3456789]\d{9}$/.test(telInput.val()) &&
					/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(emailInput.val()) &&
					/^\d{4}-\d{2}-\d{2}$/.test(bornInput.val())) {
					saveButton.prop("disabled", false); // 启用按钮
					saveButton.removeClass("disabled"); // 移除禁用样式类
				} else {
					saveButton.prop("disabled", true); // 禁用按钮
					saveButton.addClass("disabled"); // 添加禁用样式类
				}
			}

			var oldPasswordInput = $("#userinfo-oldPassword");
			var oldPasswordTip = $("#userinfo-oldPassword-tip");
			var newPasswordInput = $("#userinfo-newPassword");
			var newPasswordTip = $("#userinfo-newPassword-tip");
			var againNewPasswordInput = $("#userinfo-newPassowrd-again");
			var againNewPasswordTip = $("#userinfo-againNewPassword-tip");
			var updatePasswordButton = $("#updae-password-button");


			// 一开始就禁用按钮
			updatePasswordButton.prop("disabled", true);
			updatePasswordButton.addClass("disabled");

			// 旧密码格式验证
			oldPasswordInput.blur(function () {
				var oldPassword = oldPasswordInput.val();
				if (!/^\w{6,12}$/.test(oldPassword)) {
					oldPasswordTip.show();
					updatePasswordButton.prop("disabled", true);
					updatePasswordButton.addClass("disabled");
				} else {
					oldPasswordTip.hide();
					checkAllInput();
				}
			});

			// 新密码格式验证
			newPasswordInput.blur(function () {
				var newPassword = newPasswordInput.val();
				if (!/^\w{6,12}$/.test(newPassword)) {
					newPasswordTip.show();
					updatePasswordButton.prop("disabled", true);
					updatePasswordButton.addClass("disabled");
				} else {
					newPasswordTip.hide();
					checkAllInput();
				}
			});

			// 确认密码是否与新密码一致
			againNewPasswordInput.blur(function () {
				var newPassword = newPasswordInput.val();
				var againNewPassword = againNewPasswordInput.val();
				if (newPassword !== againNewPassword) {
					againNewPasswordTip.show();
					updatePasswordButton.prop("disabled", true);
					updatePasswordButton.addClass("disabled");
				} else {
					againNewPasswordTip.hide();
					checkAllInput();
				}
			});

			// 检查所有输入框是否都通过验证
			function checkAllInput() {
				if (/^\w{6,12}$/.test(oldPasswordInput.val()) && /^\w{6,12}$/.test(newPasswordInput.val()) &&
					newPasswordInput.val() === againNewPasswordInput.val()) {
					updatePasswordButton.prop("disabled", false);
					updatePasswordButton.removeClass("disabled");
				}
			}

			var token = localStorage.getItem('token');
			var longToken = localStorage.getItem('longToken');

			if (token && longToken) {
				var decoded = jwt_decode(longToken);
				var userId = decoded.userId;

				getEmployeeInfo(userId, token, longToken);

				$('#updae-password-button').on('click', function () {

					updatePassword(token, longToken);

				});

				$('#update-userInfo-button').on('click', function () {

					updateUserInfo(token, longToken);

				});
			} else {
				// 跳转到登录页面
				window.location.href = 'employee-login.html';
			}



		});

		// 获取数据
		function getEmployeeInfo(userId, token, longToken) {
			var url = 'http://localhost:8080/employee/findByIdController?userId=' + userId;

			if (token && longToken) {
				url += '&token=' + token + '&longToken=' + longToken;
			}

			// 发送 AJAX 请求获取数据
			$.ajax({
				url: url,
				method: 'get',
				success: function (result) {

					if (result.code === 200) {
						var datas = result.datas;

						var imageUrl = "http://localhost:8080/" + datas.imageAddress;
						var userInfo = '<h2>个人信息</h2><img src="' + imageUrl + '" alt="" id="image-address" style="border: 1px solid #ccc;"><ul>';

						userInfo += '<li><i class="fa fa-user" aria-hidden="true"></i><span>姓名</span><span>' + datas.userName + '</span></li>';
						userInfo += '<li><i class="fa fa-phone" aria-hidden="true"></i><span>手机号码</span><span>' + datas.phone + '</span></li>';
						userInfo += '<li><i class="fa fa-envelope" aria-hidden="true"></i><span>用户邮箱</span><span>' + datas.email + '</span></li>';
						userInfo += '<li><i class="fa fa-calendar" aria-hidden="true"></i><span>出生日期</span><span>' + formatDate(datas.borndate) + '</span></li>';
						userInfo += '<li><i class="fa fa-list-ul" aria-hidden="true"></i><span>员工号</span><span>' + datas.employeeAccount + '</span></li>';
						userInfo += '<li><i class="fa fa-venus-mars" aria-hidden="true"></i><span>性别</span><span>' + datas.gender + '</span></li>';
						userInfo += '</ul>';
						userInfo += '<div><input type="file" id="file-upload" style="display:none;"></div>';
						$('.box-userinfo').html(userInfo);


						$('#userinfo-name').val(datas.userName);
						$('#userinfo-tel').val(datas.phone);
						$('#userinfo-email').val(datas.email);
						$('#userinfo-bron').val(formatDate(datas.borndate));
						if (datas.gender === '男') {
							$('#inlineRadio1').prop('checked', true);
						} else {
							$('#inlineRadio2').prop('checked', true);
						}

						uploadImage(userId, token, longToken);


					} else if (result.code === 6000 || result.code === 4000) {
						// 跳转到登录
						window.location.href = 'employee-login.html';
					} else {
						alert("获取数据失败");
					}

				},
				error: function (xhr, status, error) {
					console.log("请求失败");
				}
			});
		}

		// 格式化日期
		function formatDate(date) {
			var formattedDate = new Date(date);
			var year = formattedDate.getFullYear();
			var month = ("0" + (formattedDate.getMonth() + 1)).slice(-2);
			var day = ("0" + formattedDate.getDate()).slice(-2);
			return year + "-" + month + "-" + day;
		}

		// 头像上传
		function uploadImage(userId, token, longToken) {
			$("#image-address").click(function () {
				$("#file-upload").click();
			});

			$("#file-upload").change(function () {
				var file = this.files[0];
				var formData = new FormData();
				formData.append("image", file);
				formData.append("userId", userId);

				$.ajax({
					url: "http://localhost:8080/user/uploadPathController?token=" + token + "&longToken=" + longToken,
					type: "POST",
					data: formData,
					processData: false,
					contentType: false,
					success: function (response) {
						if (response.code == 200) {
							alert("修改成功");
							// 修改操作成功后，刷新页面
							location.reload();
						} else if (response.code == 4000) {
							alert("登录已过期，请重新登录!");
							// 跳转到登录页面
							window.location.href = 'employee-login.html';
						} else {
							alert(response.msg);
						}
					},
					error: function (xhr, status, error) {
						// 文件上传失败后的处理逻辑
						alert("文件上传失败：" + error);
					}
				});
			});
		}

		// 修改密码
		function updatePassword(token, longToken) {
			var decoded = jwt_decode(longToken);
			var userId = decoded.userId;

			var oldPassword = $('#userinfo-oldPassword').val();
			var newPassword = $('#userinfo-newPassword').val();
			var againNewPassword = $('#userinfo-newPassowrd-again').val();

			// 发送保存请求
			$.ajax({
				url: "http://localhost:8080/user/updatePasswordController",
				type: "POST",
				data: {
					userId: userId,
					oldPassword: oldPassword,
					newPassword: newPassword,
					againNewPassword: againNewPassword,
					token: token,
					longToken: longToken
				},
				dataType: "json",
				success: function (data) {
					if (data.code == 200) {
						alert("修改成功,请重新登陆!");
						// 清除本地存储的 token 和 longToken
						localStorage.removeItem('token');
						localStorage.removeItem('longToken');
						// 跳转到登录
						window.location.href = 'employee-login.html';
					} else if (data.code == 4000) {
						// 跳转到登录页面
						window.location.href = 'employee-login.html';
					} else {
						alert(data.msg);
					}
				},
				error: function () {
					alert("保存失败");
				}
			});

		}

		// 修改基本资料
		function updateUserInfo(token, longToken) {
			var decoded = jwt_decode(longToken);
			var userId = decoded.userId;

			var userName = $('#userinfo-name').val(); // 获取姓名
			var phone = $('#userinfo-tel').val(); // 获取手机号码
			var email = $('#userinfo-email').val(); // 获取邮箱
			var borndate = $('#userinfo-bron').val(); // 获取出生日期
			var gender = $('input[name="inlineRadioOptions"]:checked').val(); // 获取性别

			// 发送保存请求
			$.ajax({
				url: "http://localhost:8080/user/updateInfoController",
				type: "POST",
				data: {
					userId: userId,
					userName: userName,
					phone: phone,
					email: email,
					borndate: borndate,
					gender: gender,
					token: token,
					longToken: longToken
				},
				dataType: "json",
				success: function (data) {
					if (data.code == 200) {
						alert("修改成功");
						// 修改操作成功后，刷新页面
						location.reload();
					} else if (data.code == 4000) {
						// 跳转到登录页面
						window.location.href = 'employee-login.html';
					} else {
						alert(data.msg);
						location.reload();
					}
				},
				error: function () {
					alert("保存失败");
				}
			});
		}

	</script>

	<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script src="../plugins/jQueryUI/jquery-ui.min.js"></script>
	<script>
		$.widget.bridge('uibutton', $.ui.button);
	</script>
	<script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
	<script src="../plugins/raphael/raphael-min.js"></script>
	<script src="../plugins/morris/morris.min.js"></script>
	<script src="../plugins/sparkline/jquery.sparkline.min.js"></script>
	<script src="../plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
	<script src="../plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
	<script src="../plugins/knob/jquery.knob.js"></script>
	<script src="../plugins/daterangepicker/moment.min.js"></script>
	<script src="../plugins/daterangepicker/daterangepicker.js"></script>
	<script src="../plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
	<script src="../plugins/datepicker/bootstrap-datepicker.js"></script>
	<script src="../plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
	<script src="../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
	<script src="../plugins/slimScroll/jquery.slimscroll.min.js"></script>
	<script src="../plugins/fastclick/fastclick.js"></script>
	<script src="../plugins/iCheck/icheck.min.js"></script>
	<script src="../plugins/adminLTE/js/app.min.js"></script>
	<script src="../plugins/treeTable/jquery.treetable.js"></script>
	<script src="../plugins/select2/select2.full.min.js"></script>
	<script src="../plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
	<script src="../plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
	<script src="../plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
	<script src="../plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
	<script src="../plugins/bootstrap-markdown/js/markdown.js"></script>
	<script src="../plugins/bootstrap-markdown/js/to-markdown.js"></script>
	<script src="../plugins/ckeditor/ckeditor.js"></script>
	<script src="../plugins/input-mask/jquery.inputmask.js"></script>
	<script src="../plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
	<script src="../plugins/input-mask/jquery.inputmask.extensions.js"></script>
	<script src="../plugins/datatables/jquery.dataTables.min.js"></script>
	<script src="../plugins/datatables/dataTables.bootstrap.min.js"></script>
	<script src="../plugins/chartjs/Chart.min.js"></script>
	<script src="../plugins/flot/jquery.flot.min.js"></script>
	<script src="../plugins/flot/jquery.flot.resize.min.js"></script>
	<script src="../plugins/flot/jquery.flot.pie.min.js"></script>
	<script src="../plugins/flot/jquery.flot.categories.min.js"></script>
	<script src="../plugins/ionslider/ion.rangeSlider.min.js"></script>
	<script src="../plugins/bootstrap-slider/bootstrap-slider.js"></script>
	<script src="../plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js"></script>
	<script src="../plugins/bootstrap-datetimepicker/locales/bootstrap-datetimepicker.zh-CN.js"></script>
	<script>
		$(document).ready(function () {
			// 选择框
			$(".select2").select2();

			// WYSIHTML5编辑器
			$(".textarea").wysihtml5({
				locale: 'zh-CN'
			});
		});


		// 设置激活菜单
		function setSidebarActive(tagUri) {
			var liObj = $("#" + tagUri);
			if (liObj.length > 0) {
				liObj.parent().parent().addClass("active");
				liObj.addClass("active");
			}
		}


		$(document).ready(function () {
			setSidebarActive("admin-profile");
		});

		$('.box-userinfo-right-form-update').hide();
		$('#base-info').click(function () {
			$('.box-userinfo-right-form-base').show();
			$('.box-userinfo-right-form-update').hide();
		})

		$('#update-password').click(function () {
			$('.box-userinfo-right-form-base').hide();
			$('.box-userinfo-right-form-update').show();
		})

		// 基本资料，修改密码的点击效果
		$("#base-info").click(function () {
			$(this).css({
				"color": "#1664da",
				"background-size": "100% 3px",
			});
			$("#update-password").css({
				"color": "#000",
				"background-size": "0% 3px"
			});
		});

		$("#update-password").click(function () {
			$(this).css({
				"color": "#1664da",
				"background-size": "100% 3px"
			});

			$("#base-info").css({
				"color": "#000",
				"background-size": "0% 3px"
			});
		});

	</script>
</body>

</html>